/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pl.edu.agh.student.nn.core.kohonen;

import java.util.LinkedList;
import java.util.List;
import java.util.Vector;

import pl.edu.agh.student.nn.core.InputOutputNeuron;

/**
 * @author janburkot
 */
public class KohonenNeuron extends InputOutputNeuron {

    private Vector<Integer> v;
    private double f;   //frequency of winning

    public Vector<Integer> getV() {
        return v;
    }

    public void setV(Vector<Integer> v) {
        this.v = v;
    }

    public double getDistance() {
        return distance();
    }

    private Double distance() {
        int size = super.getInputConnections().size();
        double sum = 0.0d;
        for (int i = 0; i < size; i++) {
            double weight = super.getInputConnections().get(i).getWeight();
            double input = super.getInputConnections().get(i).getFromNeuron().getOutput();
            sum += (input - weight) * (input - weight);
        }
        return Math.sqrt(sum);
    }


    public double getF() {
        return f;
    }

    public void setF(double f) {
        this.f = f;
    }
}
